{% extends 'search_index.html' %}

{% block center_block %}
{% if user == None %}
{% if errormsg != None %}
<div class="col-md-12">
  <div class="col-md-4"></div>
  <div class="col-md-4 alert alert-danger" role="alert"><strong>ERROR：</strong>{{ errormsg }}</div>
  <div class="col-md-4"></div>
</div>
{% else %}
  <p style="font-size: large">用户登录</p>
{% endif %}
<div class="col-md-3">

</div>
<div class="col-md-4">
<form class="form-horizontal center-block" action={{ request.get_full_path }} method="POST">
  {% csrf_token %}
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-6 control-label">用户名</label>
    <div class="col-sm-6">
      <input type="text" class="form-control" id="inputEmail3" placeholder="Username" name="uname">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-6 control-label">密码</label>
    <div class="col-sm-6">
      <input type="password" class="form-control" id="inputPassword3" placeholder="Password" name="upwd">
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-4 col-sm-offset-4">
      <div class="checkbox">
        <label>
          {% comment %} <input type="checkbox" name="keep" value="on"> 保持登录(14天) {% endcomment %}
          <a href="/register{% if request.GET.url != None and request.GET.url != '' %}?url={{ request.GET.url }}{% endif %}">没有帐号，去注册</a>
        </label>
      </div>
    </div>
    <div class="col-sm-3 ">
      <button type="submit" class="btn btn-default">登录</button>
      
    </div>
    <div class="col-sm-1 ">
      <a href="{% if request.GET.url == None or request.GET.url == '' %}/{% else %}{{ request.GET.url }}{% endif %}"><button type="button" class="btn btn-default navbar-right">返回</button></a>
    </div>
  </div>

</form>
</div>
<div class="col-md-5">

</div>
{% else %}
  <p style="font-size: large"><b>{{ user.name }}</b>, 您已登录</p>
  <div class="col-md-12" style="height: 10px;">

  </div>
  <div class="col-md-4">

  </div>
  <div class="col-md-4">
    <nav aria-label="...">
      <ul class="pager">
        <li><a href="{% if request.GET.url == None or request.GET.url == '' %}/{% else %}{{ request.GET.url }}{% endif %}">返回</a></li>
        <li><a href="/logout?purl={{ request.get_full_path }}">退出登录</a></li>
      </ul>
    </nav>
    <!-- /.row -->
  </div>
{% endif %}
{% endblock center_block %}